import React from 'react'
import ReactDOM from 'react-dom'
import registerServiceWorker from './model/registerServiceWorker'
import {store,action} from './model/api'

class App extends React.Component {
  constructor(props){
    super(props)
    store.dispatch(action.load())
  }
  click = () => {
    if (store.getState().lang.language === 'CN') {
      store.dispatch(action.lang('EN'))
    } else {
      store.dispatch(action.lang('CN'))
    }
    
  }
  render() {
    let sos = store.getState()
    return <div>
      hello react {sos.lang.hello}
      <button onClick={this.click}>切换语言</button>
    </div>
  }
}
ReactDOM.render(<App />, document.getElementById('root'))
registerServiceWorker()
